refactoring of some methods to make them generic.
Merge pull request #112 from darkowlzz/refactor2

refactoring of some methods to make them generic.