Refined some code