added nullpointer checks and early exceptions for null arguments