Sorted out the has many relationship query issue