added positivity check and wrote function to check local max principle