added error knowledge #252
moved to new functions for cleaner code