Altered code to remove runtime errors