Refractored, removed useless code