implemented longclicklistener and refactored code