moved bulk of code for touch event to MainActivity