debug and added comments