Updated it to work correctly