updated gallery class and added code behind