changing casting location to decleration