bug910403: Removed repeat code and added functions. Fixed Styling and Indentation.
bug910403: Removed repeat code and added functions. Fixed Styling and Indentation.
merging changes