Fixed syntax bug because of rearranging code.