changed to already defined function for removing undefined values