Refactored credentials class
Added error checking