fixed bugs with button code