added saving to png but still needs to be improved