Updated polygon functionality. removed bugs