Moved event handlers to inside onready function