Code tidy in buttonpress()