Modified by Vijay with changes to PMViewController