Thank you for the reply everyone. Each of you put some thoughts inside and gave a different idea that helped me to handle this problem. Thanks a lot!
The final solution I made was using @karlgoethebier post (talking about the 16 years old post of @merlyn), I combined it with stat function, which @Laurent_R and @davido suggested. Thanks a lot!