Refactored some code and added a epstheta func