Fixed bug in touch function