Changed code according to comments (except the work with SQLite).