Updated to work properly