Updated code to work