fix minor mistake and moved function