added function from stefans connection.java