Working code as an update,changes still has to be made,not final