Updated code

Re-factored some lines