Made console.logs clearer and cleaned up code