making some changes
added nullable type checks and argument checking function wrapper