Updated to support ticket type parameter and removed extra query lines