Fixed alignment issues and added a condition while saving

Fixed alignment issues and added a condition while saving